//引入路由组件
//引入Home组件
// import Home from "@/pages/Home"
//引入Login组件
// import Login from "@/pages/Login"
//引入Search组件
// import Search from "@/pages/Search"
//引入Register组件
// import Register from "@/pages/Register"
//引入Detail组件
// import Detail from "@/pages/Detail"
//引入addcartsuccess组件
// import AddCartSuccess from "@/pages/AddCartSuccess"
//引入shopCart组件
// import shopCart from "@/pages/ShopCart"
//引入Trade组件
// import trade from "@/pages/Trade"
//引入Pay组件
// import pay from "@/pages/Pay"
//引入Paysuccess组件
// import paysuccess from "@/pages/PaySuccess"
//引入Center组件
// import center from "@/pages/Center"
//引入myorder组件
// import myorder from "@/pages/Center/MyOrder"
//引入Center组件
// import grouporder from "@/pages/Center/GroupOrder"

export default [
  {
    path:"/center",
    component:()=>import("@/pages/Center"),
    meta:{
      show:true
    },
    children:[
      {
        path:"myorder",
        component:()=>import("@/pages/Center/MyOrder"),
      },
      {
        path:"grouporder",
        component:()=>import("@/pages/Center/GroupOrder"),
      }
    ],
    //当center的时候，重定向path为"/center/myorder"
    redirect:"/center/myorder",
  },
  {
    path:"/paysuccess",
    component:()=>import("@/pages/PaySuccess"),
    meta:{
      show:true
    },
    beforeEnter:(to,from,next) =>{
      //进入paysuccess的，必须是从pay来的
      if(from.path == "/pay"){
        next()
      }else {
        //否则就停留在原地组件
        next(false)
      }
    }
  },
  {
    path:"/pay",
    component:()=>import("@/pages/Pay"),
    meta:{
      show:true
    },
    beforeEnter:(to,from,next) =>{
      //进入pay的，必须是从trade来的
      if(from.path == "/trade"){
        next()
      }else {
        //否则就停留在原地组件
        next(false)
      }
    }
  },
  {
    path:"/trade",
    component:()=>import("@/pages/Trade"),
    meta:{
      show:false
    },
    beforeEnter: (to, from, next) => {
      //去交易页面，必须是从购物车而来的
      if(from.path == "/shopcart") {
        next()
      }else {
        //否则就停留在原地组件
        next(false)
      }
    }
  },
  {
    path:"/home",
    component:()=>import("@/pages/Home"),
    meta:{
      show:true
    }
  },
  {
    path:"/login",
    component:()=>import("@/pages/Login"),
    meta:{
      show:false
    }
  },
  {
    path:"/search/:keyword?",
    component:()=>import("@/pages/Search"),
    meta:{
      show:true
    },
    name:"search"
  },
  {
    path:"/register",
    component:()=>import("@/pages/Register"),
    meta:{
      show:false
    }
  },
  {
    path:"/detail",
    component:()=>import("@/pages/Detail"),
    meta:{
      show:true
    }
  },
  {
    path:"/shopcart",
    component:()=>import("@/pages/ShopCart"),
    meta:{
      show:true
    }
  },
  {
    path:"/addcartsuccess",
    component:()=>import("@/pages/AddCartSuccess"),
    meta:{
      show:true
    }
  },
  //设置路由重定向
  {
    path:"*",
    // component:Home,
    redirect:"/home",
    meta:{
      show:true
    }
  }
]